package com.zhuss.product.site;

import com.zhuss.bean.bo.product.site.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.DzcxException;

/**
 * @description: 站点操作的Service
 * @author: zhushanshuo
 * @create: Wed Dec 30 08:43:41 CST 2020
 **/
@Component("siteOperateService")
public class SiteOperateService implements OperateService<Void, Object> {

	@Autowired
	@Qualifier("siteCreate")
	private Processor<Object, CreateSiteBo> siteCreate;

	@Autowired
	@Qualifier("siteUpdate")
	private Processor<Object, UpdateSiteBo> siteUpdate;

	@Autowired
	@Qualifier("siteDelete")
	private Processor<Object, DeleteSiteBo> siteDelete;

	@Autowired
	@Qualifier("siteStart")
	private Processor<Object, StartSiteBo> siteStart;

	@Autowired
	@Qualifier("siteStop")
	private Processor<Object, StopSiteBo> siteStop;


	/**
	 * 创建
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
	public Void create(Object param) throws DzcxException {

		CreateSiteBo bo = (CreateSiteBo) param;

		siteCreate.process(bo);

		return null;
	}

	/**
	 * 修改
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
    public Void update(Object param) throws DzcxException {

		UpdateSiteBo bo = (UpdateSiteBo) param;

		siteUpdate.process(bo);

    	return null;
    }

	/**
	 * 删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public Void delete(Object param) throws DzcxException {

		DeleteSiteBo bo = (DeleteSiteBo) param;

		siteDelete.process(bo);

		return null;
	}


	/**
	 * 启用
	 */
	@Transactional(rollbackFor = Exception.class)
	protected Void start(Object param) throws DzcxException {

		StartSiteBo bo = (StartSiteBo) param;

		siteStart.process(bo);

		return null;
	}

	/**
	 * 停用
	 */
	@Transactional(rollbackFor = Exception.class)
	protected Void stop(Object param) throws DzcxException {

		StopSiteBo bo = (StopSiteBo) param;
//
		siteStop.process(bo);

		return null;
	}


}

